<?



ob_start(); 
include("common/header.html");
include("common/left.html");
include("common/page.php");
include("class/OrderRecord.php");
include("class/ProOrder.php");
include("class/SimpleExcel.class.php");
$out_html=ob_get_contents();
ob_end_clean();
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s= new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$memberID=$_SESSION['sid'];
$str="select id,imgpath from uu_land";
$images=array();
$GLOBALS['le']->query($str);
while($row=$GLOBALS['le']->fetch_assoc()){
	$images[$row['id']]=$row['imgpath'];
}

$pOrder=buyProOrderObject($memberID,$s, 'TRANS');
$v['title'] ="分销订单";
$v['title2']="直销订单";
$v['from']="buy";
$currentPage=$_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize=$_REQUEST['pageSize']?$_REQUEST["pageSize"]:15;
$concat=0;
// 导出全部订单
if(isset($_REQUEST['act']) && $_REQUEST['act']=="Export"){
	$currentPage=1;
	$pageSize=99999;
	$concat=0;
}
$r=$pOrder->_orderlist($currentPage,$pageSize,$concat);
$orderCount = $ticketCount = $allMoney = 0;// 订单统计信息
if($_GET['a']){
	print_r($r);
}
//  获取产品对应的供应商列表
if(count($r)){
	$adis = array();
	foreach($r as $key=>$row){
		if(!isset($adis[(string)$row['mainOrder']->UUaid]))
			$adis[(string)$row['mainOrder']->UUaid]=(string)$row['mainOrder']->UUaid;
		// 统计订单信息
		$orderCount++;
		$ticketCount+=(string)$row['mainOrder']->UUtnum;
		$allMoney+=((int)$row['mainOrder']->UUtotalmoney)/100;
	}
	$str="select id,dname from pft_member where dtype=0 AND id IN (".implode(',',$adis).")";
	$anames=array();
	$GLOBALS['le']->query($str);
	while($row=$GLOBALS['le']->fetch_assoc())
		$anames[$row['id']]=$row['dname'];
}

// 获取对应的供应商
if($_SERVER['HTTP_REQUEST_TYPE']=='getDistors' || $_REQUEST['tjs']==5){
	include 'getDistors.php';
    $DistorsNames = getDistors($GLOBALS['le']);
	
	// 异步获取对应的供应商
	if($_SERVER['HTTP_REQUEST_TYPE']=='getDistors'){
		echo json_encode(array('s'=>'success','d'=>$DistorsNames));
		exit;
	}
}
$dTypeName = '供应商';
$atype= 'buy';// 导出文件名判断条件
include("loadExcel_simple.php");
echo $out_html;
// 判断订单是否为主订单  true为主订单
function isMainOrder($field){
	return ($field=='main' || $field!=0 ) ? true:false;
}
// 复票订单主订单
function echoMainOrder($obj){
	return ((String)$obj->UUconcat_id=='main') ? (String)$obj->UUordernum:(String)$obj->UUconcat_id;
}
$count=$pOrder->orderlistTotal();
$buyFlag = true;
$uuStatus = array(0=>"未使用",1=>"<em class='green'>已使用</em>",2=>"已过期",3=>"<em class='red'>已取消</em>",4=>"被替代",5=>"被修改",6=>"已撤销",7=>"部分使用");
// 不显示分销商列
$showDtrArr = array(2223);
$showDtr = true;
if(in_array($_SESSION['sid'], $showDtrArr)){
	$showDtr = false;
}
include("tpl/orderLists_trans2.tpl");
include("common/footer.html");
?>